// pages/wallet/wallet.js
var app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
	  balance:'0.00',
    is_shouru: true,
    have_money:false,
    have_yue:false
  },
  tixian:function(){
    this.setData({
      is_tixian:true,
      is_shouru:false
    })
    var id = wx.getStorageSync('uid')
    var that = this
    wx.request({
      url: app.globalData.url + 'xcx/getMoneyActLog/' + id + '/3',
      method: "get",
      success: function (res) {
        console.log(res)
        if (res.data.data) {
          that.setData({
            yuelist: res.data.data,
            have_yue: true

          })
        }
      }
    })


    
  },
  shouru:function(){
    this.setData({
      is_tixian: false,
      is_shouru: true
    })



  },
  bank:function(){
    var money = this.data.balance
    if(money>=0){
      wx.navigateTo({
        url: '../wechat/wechat',
      })
    }else{
      wx.showToast({
        title: '余额需大于等于10',
        icon: 'none',
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var id = wx.getStorageSync('uid')
    var that = this
    wx.request({
      url: app.globalData.url + 'xcx/getNowCard/' + id,
      data: {},
      method: "get",
      success: function (res) {
        console.log(res)
        if (res.data.code == 10000) {
            that.setData({
              headimgurl: res.data.data.card_img
            })
        } else {
         
         
        }
      }
    })

    wx.request({
      url: app.globalData.url +'xcx/getNowMoney/'+id,
      method:"get",
      success:function(res){
        console.log(res)
        if(res.data.data){
          that.setData({
            balance: res.data.data.amount
          })
        }
      }
    })

    wx.request({
      url: app.globalData.url + 'xcx/getMoneyActLog/' + id+'/0',
      method: "get",
      success: function (res) {
        console.log(res)
        if (res.data.data) {
          that.setData({
            list: res.data.data,
            have_money:true

          })
        }
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})